<%@ page language="java" contentType="text/html; charset=UTF-8" import="cn.com.dashihui.web.common.OrderCode" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html>
<html>
<head>
    <title>管理平台</title>
    <jsp:include page="../../../include/header.jsp"></jsp:include>
        <style type="text/css">
			table td{
			text-align: center;
			}
		 	table th{
			text-align: center;
		 	}
		</style>
</head>
<body>
<div id="wrapper">
	<jsp:include page="../../../include/nav.jsp"></jsp:include>
	<div id="page-wrapper">
	<div class="row">
			<div class="col-lg-12">
				<h1 class="page-header">${name } <k font-size="12px;">订单统计</k></h1>
			</div>
		</div>
		<!-- 搜索框 -->		
			<div class="col-lg-offset-2 col-lg-10">
				<label class="search-label">选择门店：</label>
				<select id="sStoreId" class="selectpicker pull-left p-l-5" data-width="15%" data-url="${BASE_PATH}/api/Orderstore/${sellerId}" data-isfirst="true"  data-key="storeid:title"></select> 
				<label class="search-label">订单状态：</label>
				<div class="search-input">
					<select id="sState" class="selectpicker" data-width="150">
						<option value="0">全部</option>
					<option value="1">待付款</option>
					<option value="2">待出库</option>
					<option value="3">待评价</option>
					<option value="4">已完成</option>
					<option value="5">已删除</option>
					<option value="6">待收货</option>
							
					</select>
				</div>
				<button class="btn btn-success search-btn" onclick="query();">确定</button>
				<div class="clearfix"></div>
			</div>
		<div><p></p></div>
		<div class="row">
			<div class="col-lg-12">
				<div class="row">
					<div>
						<div class="text-muted single-line-text pull-left">共 <font color="#428bca" id="dataCount">0</font> 条记录</div>
					  <button onclick="doExcel();" style="float:right;margin-right: 30px;background-color: #419641;color: white;border:2px solid;background-image: linear-gradient(to bottom,#5cb85c 0,#419641 100%);">导出</button>
					</div>					
				</div>
			
			<div class="table-responsive panel panel-default">
					<table id="dataTable" class="table table-hover table-bordered " style=" overflow:scroll">
			            <thead>
			                <tr>			               		
								<th width="200px;">订单号</th>
								<th width="80px;">会员姓名</th>
								<th width="150px;">会员卡号</th>
								<th width="120px;">联系方式</th>
								<th width="100px;">下单分公司</th>
								<th width="200px;">下单时间</th>
								<th width="80px;">订单总价值</th>
								<th width="200px;">支付时间</th>
								<th width="100px;">营业部</th>
								<th width="100px;">状态</th>								
			                </tr>
			            </thead>
			            <tbody id="dataList"></tbody>
			        </table>
				</div>
		        <div class="row">
		        	<div class="col-lg-12">
		        		<ul id="dataPagination" class="pagination-sm pull-right"></ul>
		        	</div>
		        </div>
			</div>
		</div>
	</div>
	</div>
	<jsp:include page="../../../include/footer.jsp"></jsp:include>
<jsp:include page="../../../include/javascripts.jsp"></jsp:include>
<!-- 异步加载下一页数据后，用模板渲染 -->
 <script type="text/html" id="dataTpl">
  {{each list as item}}
				 <tr id="item{{item.orderNum}}" data-id="{{item.orderNum}}">
					<td><a href="javascript:showOrder('{{item.orderNum}}');"><font color="#40a9ff" ="dataCount">{{item.orderNum}}</font></a></td>
					<td><a href="javascript:showUser('{{item.uid}}');"><font color="#40a9ff" id="dataCount">{{item.name}}</font></a></td>
                    <td>{{item.card}}</td>
					<td>{{item.tel}}</td>
                    <td>{{item.xdstore}}</td>
					<td>{{item.startDate}}</td>
					<td>{{item.amount}}</td>
					<td>{{item.payDate}}</td>
					<td>{{item.toBossOneId}}</td>
					{{if item.payState == <%=OrderCode.OrderPayState.NO_PAY%>}}
							{{if item.delState==<%=OrderCode.DelState.NO%>}}
								<td>待付款</td>
							{{else if item.delState==<%=OrderCode.DelState.YES%>}}
								<td>已取消</td>
							{{/if}}
					{{else if item.payState == <%=OrderCode.OrderPayState.HAD_PAY%>}}
						{{if item.orderState == <%=OrderCode.OrderState.NO_CON%>}}
							{{if item.tuistate==<%=OrderCode.RefundState.ZERO%>}}
								<td>未兑换</td>
							{{else if item.tuistate==<%=OrderCode.RefundState.VERIFYING%>}}
								<td>退款中</td>
							{{else if item.tuistate==<%=OrderCode.RefundState.REFUNDED%>}} 
								<td>已退款</td>
							{{/if}}
						{{else if item.orderState== <%=OrderCode.OrderState.had_CON%>}}
						{{else if item.orderState== <%=OrderCode.OrderState.EXPIRE%>}}
							{{if item.tuistate==<%=OrderCode.RefundState.ZERO%>}}
								<td>已过期</td>
							{{else if item.tuistate==<%=OrderCode.RefundState.VERIFYING%>}}
								<td>退款中</td>
							{{else if item.tuistate==<%=OrderCode.RefundState.REFUNDED%>}}
								<td>已退款</td>
							{{/if}}
						{{/if}}
					{{/if}}
				</tr>
		{{/each}}
</script>
 <script type="text/javascript">
var dataPaginator;
$(query);
function query(){
	var id=${id};orderState=$("#sState").val(),storeid = $("#sStoreId").val();
	if(dataPaginator){
	  dataPaginator.destroy();
	}
	dataPaginator = Kit.pagination("#dataPagination","${BASE_PATH}/bus/goods/store/doDetail",{id:id,storeid:storeid,orderState:orderState,"pageSize":10},function(result){
		//设置显示最新的数据数量
		$("#dataCount").html(result.object.totalRow);
		//根据模板渲染数据并填充
		$("#dataList").empty().append(template("dataTpl",result.object));
	});
}

function doExcel(){
	var id=${id};
	 var orderNum=$("#sOrderNum").val(),state = $("#sState").val();
	window.location.href="${BASE_PATH}/bus/goods/store/doExceljy?id="+id+"&orderNum="+orderNum+"&state="+state;
}
</script>
</body>
</html>